home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload Trio 2
/
Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO
/
dir37
/
mxmenu.zip
/
NOVTRANS.MNU
< prev
next >
Wrap
Text File
|
1993-07-15
|
15KB
|
477 lines
Comment
========================================================================
Novell menu to MarxMenu Translator:
Copyright 1989-92 by Marc Perkel * All rights reserved.
Usage: MARXMENU NOVTRANS <novell menu>
This program was written to translate Novell menus to MarxMenus. It is
not an exact translation, but does the bulk of the work. It is up to you
to edit the output file and tune the menu the way you want.
I have made no attempt to copy color information. I am not presenting
selections in sorted order, but in the order in which they are defined.
If the translation is successful then your old menu will be renamed with
a NOV extension.
========================================================================
EndComment
Var
Menus
MenuPtr
CommandPtr
LinePtr
ThisMenu
ThisChoice
BoxDim
VarNum
PromptLine
Out
Cap
InputAVar
NovellFileName
MarxMenuFileName
NovellTempFileName
NovFileExists
Greek
Titles
QuietMode
NovLines
;----- Translator Messages
Const
TopMessage = "Joe Blow's Master Menu"
BottomMessage = "*-<< Acme Manufacturing Company >>-*"
;----- If you want the Greek Column effect, set to true
Greek = False
Qualifier MenuName MenuTitle YPos XPos MenuColor MenuChoices
Qualifier ChoiceName ChoiceCmd
Comment
========================================================================
This is the main body of the NovTrans Program.
========================================================================
EndComment
if not NetWorkVersion
ClearScreen
Writeln
Writeln 'This translator requires the network version of MarxMenu to Run!'
endif
PreAmble
GetFileNames
Parse
if MenuPtr = 0
Writeln
Writeln
Writeln 'Error: ' NovellTempFileName ' is not a Novell menu!
ExitMenu
endif
Header
WriteOutMenus
Footer
ClearScreenFirst Off
Writeln
if QuietMode
Execute 'MARXCOMP.EXE ' + MarxMenuFileName + ' /U'
else
Execute 'MARXCOMP.EXE ' + MarxMenuFileName
endif
if ReturnCode = 0
Writeln
Writeln 'Menu Translation Sucessful!'
Writeln
if not NovFileExists and not QuietMode
Writeln 'Renaming ' NovellTempFileName ' to ' ForceExtension(NovellTempFileName,'NOV')
FileRename(NovellTempFileName,ForceExtension(NovellTempFileName,'NOV'))
Writeln 'Renaming ' MarxMenuFileName ' to ' NovellTempFileName
FileRename(MarxMenuFileName,NovellTempFileName)
Writeln
Write 'Your original novell menu has been renamed to: '
Writeln ForceExtension(NovellTempFileName,'NOV')
Writeln
endif
Writeln 'To test your menu type MARX ' NovellFileName '.
endif
ExitMenu
Comment
=====================================
Subroutine area.
=====================================
EndComment
;----- Initilize Variables and Environment
Procedure PreAmble
ClearScreenOnExit Off
if UpperCase(ParamStr(3)) = 'U'
Quietmode = True
OutFile = 'NUL'
endif
StandardIO
Writeln
NovellFileName = UpperCase(ParamStr(2))
if Extension(NovellFileName) = 'MNU'
length(NovellFileName) = length(NovellFileName) - 4
endif
Usage
EndProc
;----- Proper Usage Procedure
Procedure Usage
if NovellFileName = ''
Writeln('Converts Novell menus to MarxMenus.')
Writeln
Writeln(' Usage: MarxMenu NovTrans <menu>')
ExitMenu
endif
EndProc
;----- Get File Names
Procedure GetFileNames
if pos('.',NovellFileName) = 0
if QuietMode
NovellTempFileName = ForceExtension(NovellFileName,'MNU')
else
NovellTempFileName = ForceExtension(NovellFileName,'NOV')
if ExistOnPath(NovellTempFileName) = ''
NovellTempFileName = ForceExtension(NovellFileName,'MNU')
else
NovFileExists = True
endif
endif
endif
NovellTempFileName = ExistOnPath(NovellTempFileName)
if NovellTempFileName = ''
Writeln 'Error: ' NovellFileName ' does not exist!'
ExitMenu
endif
if NovFileExists
MarxMenuFileName = ForceExtension(NovellTempFileName,'MNU')
else
MarxMenuFileName = ForceExtension(NovellTempFileName,'TMP')
endif
ReadTextFile(NovellTempFileName,NovLines)
Writeln 'Creating ' MarxMenuFileName
EndProc
Procedure BlankLine
FileWriteln(Out,'')
EndProc
;----- Write out the MarxMenu Source Header
Procedure Header
FileAssign(Out,MarxMenuFileName)
FileCreate(Out)
BlankLine
FileWriteln(Out,'Comment')
FileWriteln(Out,'==========================================================')
BlankLine
FileWriteln(Out,'This file was converted from Novell Menu: ',NovellTempFileName)
BlankLine
FileWriteln(Out,'It should behave in a similar way to the original menu but')
FileWriteln(Out,'not necessarilly exactly the same. It will be close enough')
FileWriteln(Out,'for you to fine tune it the way you want.')
BlankLine
FileWriteln(Out,'To add a choice to a menu simply use the AddChoice command')
FileWriteln(Out,'then add the appropiate Onkey statement.')
FileWriteln(Out,'The menu will make the size adjustments accordinaly.')
BlankLine
FileWriteln(Out,' Example:')
FileWriteln(Out,' AddChoice("Print Console",10)')
FileWriteln(Out,' ... ')
FileWriteln(Out,' ... ')
FileWriteln(Out,' OnKey Task(10)')
FileWriteln(Out,' cd \public')
FileWriteln(Out,' PConsole')
FileWriteln(Out,' ...')
BlankLine
FileWriteln(Out,"If you want to change the menu's center, pass the XY")
FileWriteln(Out,"coordinates to menu's CenterStretchBox procedure.")
BlankLine
FileWriteln(Out,' Example:')
FileWriteln(Out,' CenterStretchBox("Menu Header",40,12)')
BlankLine
FileWriteln(Out,'This will cause the menu to center at Col 40, Row 12')
BlankLine
FileWriteln(Out,'Instead of defining the center of the box, there is a command')
FileWriteln(Out,'CornerStretchBox where the box grows down and right.')
BlankLine
FileWriteln(Out,' Example:')
FileWriteln(Out,' CornerStretchBox("Menu Header",8,6)')
BlankLine
FileWriteln(Out,'To control custom features, edit CUSTOM.INC and other INCLUDE Files.')
BlankLine
FileWriteln(Out,'=========================================================')
FileWriteln(Out,'EndComment')
BlankLine
FileWriteln(Out,';----- Create Variables')
BlankLine
FileWriteln(Out,'var')
FileWriteln(Out,' NovVar')
FileWriteln(Out,' KeepUsersInMenu')
BlankLine
BlankLine
FileWriteln(Out,';----- Here is where you add you own menu title and status line message')
BlankLine
FileWriteln(Out,'MenuTitle = "',TopMessage,'"')
FileWriteln(Out,'StatusLineText = "',BottomMessage,'"')
BlankLine
FileWriteln(Out,';----- Load Novell look and feel routines')
BlankLine
FileWriteln(Out,'Include "CUSTOM.INC"')
if Greek then FileWriteln(Out,'Greek = True')
BlankLine
FileWriteln(Out,'KeepUsersInMenu Off ;Change to On to keep users in menu.')
BlankLine
FileWriteln(Out,'Comment')
FileWriteln(Out,'=================================')
BlankLine
FileWriteln(Out,'MarxMenu is capable of software metering. This means that it can')
FileWriteln(Out,'limit the number of users of an application to a fixed amount.')
BlankLine
FileWriteln(Out,' OnKey Task (2)')
FileWriteln(Out," |if Limit('LOTUS',6) then Return ;limit Lotus to 6 Users")
FileWriteln(Out,' CD \PUBLIC\LOTUS')
FileWriteln(Out,' 123')
BlankLine
FileWriteln(Out,'Read the METER.INC file for more details.')
BlankLine
FileWriteln(Out,'=================================')
FileWriteln(Out,'EndComment')
BlankLine
FileWriteln(Out,"Include 'METER.INC' ;Software Metering")
BlankLine
FileWriteln(Out,'Comment')
FileWriteln(Out,'=================================')
BlankLine
FileWriteln(Out,'In order to add menu choices conditionally you would append the')
FileWriteln(Out,'choices to the end of the array after all the default choices')
FileWriteln(Out,'are set. For Example:')
BlankLine
FileWriteln(Out,' if InGroup("ACCOUNTING")')
FileWriteln(Out,' AddChoice("Payroll Menu",10)')
FileWriteln(Out,' endif')
BlankLine
FileWriteln(Out,'Here is where menus are created.')
BlankLine
FileWriteln(Out,'=================================')
FileWriteln(Out,'EndComment')
BlankLine
FileFlush(Out);
EndProc
;----- Write out the MarxMenu Source Footer
Procedure Footer
BlankLine
FileWriteln(Out,';----- End of Menu Translation')
FileClose(Out)
EndProc
;----- Preprocess Lines
Procedure Parse
Var ChoicePtr TotalLines X St St2
TotalLines = NumberOfElements(NovLines)
Writeln('Parsing Novell Menu source code ...')
MenuPtr = 0
loop(TotalLines)
if (LoopIndex Mod 10 = 0) or (LoopIndex = TotalLines)
Write Cr
Write('Processing Line # ',LoopIndex,' of ',TotalLines)
endif
if left(NovLines[LoopIndex],1) = '%'
ChoicePtr = 0
CommandPtr = 0
MenuPtr = MenuPtr + 1
Actual ThisMenu = Loc Menus[MenuPtr]
St = mid(NovLines[LoopIndex],2,255)
X = pos(',',St)
if X = 0 then X = succ(Length(St))
ThisMenu.MenuTitle = left(St,X - 1)
Trim(ThisMenu.MenuTitle)
AppendArray(Titles,UpperCase(ThisMenu.MenuTitle))
delete(St,1,X)
St2 = ' '
if MenuPtr < 10 then St2 = St2 + ' '
ThisMenu.MenuName = 'Menu' + Str(MenuPtr) + St2 + '{' + ThisMenu.MenuTitle + '}'
ThisMenu.YPos = value(NextWord(St))
ThisMenu.XPos = value(NextWord(St))
ThisMenu.MenuColor = value(NextWord(St))
else
if left(NovLines[LoopIndex],1) > ' '
CommandPtr = 0
ChoicePtr = ChoicePtr + 1
Trim(NovLines[LoopIndex])
if Mid(NovLines[LoopIndex], 2, 1) = '.'
Delete(NovLines[LoopIndex],1,2)
Trim(NovLines[LoopIndex])
endif
;----- Get rid of multiple spaces
while pos(' ',NovLines[LoopIndex]) > 0
delete(NovLines[LoopIndex],pos(' ',NovLines[LoopIndex]),1)
endwhile
;----- Get rid of double quotes
while pos('"',NovLines[LoopIndex]) > 0
delete(NovLines[LoopIndex],pos('"',NovLines[LoopIndex]),1)
endwhile
ThisMenu.MenuChoices[ChoicePtr].ChoiceName = NovLines[LoopIndex]
else
if NovLines[LoopIndex] > ''
if ChoicePtr = 0
Writeln
Writeln 'Error in menu line: ' LoopIndex
ExitMenu
endif
CommandPtr = CommandPtr + 1
ThisMenu.MenuChoices[ChoicePtr].ChoiceCmd[CommandPtr] = NovLines[LoopIndex]
endif
endif
endif
endloop
EndProc
;----- Create the Menu Choices Array
Procedure WriteOutMenuChoices
Writeln
Write('Translating: ' + ThisMenu.MenuName + ' ... ')
BlankLine
FileWriteln(Out,';=============[ ' + ThisMenu.MenuTitle + ' ]============*')
BlankLine
if MenuPtr > 1
FileWriteln(Out,':',Left(ThisMenu.MenuName,pred(pos(' ',ThisMenu.MenuName))))
BlankLine
endif
loop ThisMenu.MenuChoices
FileWriteln(Out,' AddChoice("' + ThisMenu.MenuChoices[LoopIndex].ChoiceName + '",' + Str(LoopIndex) + ')')
endloop
BlankLine
FileWriteln(Out,'CenterStretchBox("' + ThisMenu.MenuTitle + '",' + Str(ThisMenu.XPos) + ',' + Str(ThisMenu.YPos) + ')')
BlankLine
EndProc
;----- Create the Onkey Statements
Procedure WriteOutOnkeyChoices
var Tmp St X Y Z
loop ThisMenu.MenuChoices
Actual ThisChoice = Loc ThisMenu.MenuChoices[LoopIndex]
Tmp = ThisChoice.ChoiceName
FileWriteln(Out,'OnKey Task(' + Str(LoopIndex) + ')')
loop ThisChoice.ChoiceCmd
CommandPtr = LoopIndex
Tmp = ThisChoice.ChoiceCmd[CommandPtr]
Trim(Tmp)
if UpperCase(Tmp) = '!LOGOUT' then Tmp = '|Logoff'
if Left(Tmp,1) = '%'
delete(Tmp,1,1)
X = PosInList(UpperCase(Tmp),Titles)
if X = 0
Writeln
Writeln 'Error: Menu ' Tmp ' not Found!'
ExitMenu
endif
Tmp = '^' + Menus[X].MenuName
endif
if (pos('@',Tmp) > 0) and (Pos('@ECHO',UpperCase(Tmp)) = 0)
X = 1
while X <= length(Tmp)
while (X <= length(Tmp)) and (mid(Tmp,X,1) <> '@')
X = X + 1
endwhile
Z[1] = mid(Tmp,X,1)
Z[2] = mid(Tmp,X + 1,1)
if (Z[1] = '@') and (((Z[2] > '0') and (Z[3] <= '9')) or (Z[2] = '"'))
if Z[2] = '"'
insert(' ',Tmp,X + 1)
VarNum = 10
else
VarNum = ord(Z[2]) - 48
endif
InputAVar = mid(Tmp,X + 2,1) = '"'
if InputAVar
Y = X + 3
while (mid(Tmp,Y,1) <> '"') and (Y <= length(Tmp))
Y = Y + 1
endwhile
PromptLine = mid(Tmp,X + 3,Y - (X + 3))
else
Y = X + 1
endif
delete(Tmp,X,Y - X + 1)
insert('" NovVar[' + Str(VarNum) + '] "',Tmp,X)
if InputAVar
FileWriteln(Out,' |NovVar[' Str(VarNum) '] = ReadTextLine("' + PromptLine + '","",0,21)')
FileWriteln(Out,' |if LastKey = Esc')
FileWriteln(Out,' |LastKey = " "')
FileWriteln(Out,' | Return ;Abort if ESC Pressed')
FileWriteln(Out,' |endif')
endif
endif
endwhile
Tmp = '|Bat "' + Tmp + '"'
if right(Tmp,2) = '""'
length(Tmp) = length(Tmp) - 2
endif
Trim(Tmp)
endif
FileWriteln(Out,' ' + Tmp)
endloop
BlankLine
endloop
EndProc
;----- Create the Menus
Procedure WriteOutMenus
Writeln
Loop Menus
MenuPtr = LoopIndex
Actual ThisMenu = Loc Menus[MenuPtr]
WriteOutMenuChoices
WriteOutOnkeyChoices
if MenuPtr = 1
FileWriteln(Out,'OnKey ESC')
FileWriteln(Out,' |if not KeepUsersInMenu or NovConsoleOperator')
FileWriteln(Out,' | LeaveMenu')
FileWriteln(Out,' |endif')
BlankLine
endif
EndLoop
EndProc